home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / comm / yep16.zip / YEPU.ZIP / YEPUFOLD.CMD < prev    next >
OS/2 REXX Batch file  |  1996-02-17  |  7KB  |  178 lines

  1. /* YEPuFOLD.CMD -- YEP URL log file to IBM Web Explorer Objects in folder.
  2.  
  3.  - please edit the line below to reflect the path/filename of your Log,
  4.    or specify filename on command line. I.E. Yepufold url.log 
  5.  
  6.  - if the folder does not exist it is created on the desktop. After it 
  7.    is created, you can move it to wherever you want it.
  8.  - if you want to have multiple folders then edit the UrlFolder variable
  9.    below-- perhaps make different copies of this script.
  10.    
  11.  - **WARNING** i'd be shocked to death if this works on FAT partitions.
  12.    It shouldn't be dangerous to try... but be ready for error messages.
  13.    
  14. - The full entry of the URL capture is put in the COMMENTS for the object.
  15.   To access this go to the Settings|File folder and click to page 3....
  16.   It's messy, but all info is preserved... maybe can think of a better way.
  17.   
  18. */
  19.  
  20.  
  21. UrlFolder = 'Yep Urls'
  22. UrlLog = 'c:\osu\yarn\url.log'
  23.  
  24. BetweenRecords = 1;
  25. UrlNum = 0
  26. URLS. = ''
  27. Records = 0
  28.  
  29. Parse arg ln
  30. if (ln \= '') then UrlLog = ln
  31.  
  32. Say 'Converting Yep Url Log to Web Explorer Objects in a folder...'
  33.  
  34. Call RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs';
  35. Call SysLoadFuncs;
  36.  
  37. FolderID = '<'||translate(UrlFolder,' ','_')||'>'
  38. FolderPlace = '<WP_DESKTOP>'
  39. FolderClass = 'WPFolder'
  40.  
  41. /* lets see if there's a log file before continuing! */
  42. ret = stream(UrlLog,'c','open read')
  43. if ret <> 'READY:' then do
  44.     say 'Can not seem to be able to open "'UrlLog'" to read.'
  45.     exit
  46. end
  47.  
  48. /* try to make a folder in case it doesn't exist already */
  49. ret = SysCreateObject(FolderClass, UrlFolder, FolderPlace,,
  50.                       'OBJECTID='||FolderID, 'fail');
  51.  
  52. /* Hack to find path to desktop -- idea stolen from MakeUrl.cmd */
  53. call SysIni 'BOTH', 'FolderWorkareaRunningObjects', 'ALL:', 'list.'
  54. if result = 'ERROR:' then do
  55.   say "Cannot find desktop??"
  56.   exit
  57. end
  58. desktop = list.1;
  59.  
  60. /* why not give the folder a subject? Ever seen the Subject field used?! */
  61. rc = SysPutEA(desktop||'\'||UrlFolder, '.SUBJECT',,
  62.                    'FDFF'x||D2C(11)||'00'x||'Yep Url Log')
  63.  
  64. /* here we go... routines hacked from YEPuDUPE.cmd... reuse code! */
  65. do while lines(UrlLog)<>0
  66.     ln = linein(UrlLog)
  67.     
  68.     if (ln \= '') & (BetweenRecords = 1) then do
  69.         BetweenRecords = 0;        
  70.         RecordLines = 0
  71.         Duplicate = 0
  72.         Records = Records + 1
  73.     end
  74.     
  75.     if (ln \= '') & (BetweenRecords = 0) & (duplicate = 0) then do
  76.         RecordLines = RecordLines + 1
  77.         Arecord.RecordLines = ln
  78.         if SubStr(ln,1,4) == 'URL:' then do
  79.             do x = 1 to UrlNum 
  80.                 if URLS.x = ln then Duplicate = 1
  81.             end
  82.             if Duplicate = 0 then do
  83.                 UrlNum = UrlNum + 1
  84.                 URLS.UrlNum = ln
  85.             end            
  86.         end
  87.     end
  88.  
  89.     if (ln == '') & (BetweenRecords = 0) then do
  90.         betweenRecords = 1;
  91.         if Duplicate = 0 then do
  92.             TheUrl = word(Urls.UrlNum,2)
  93.             fnUrl = Translate(TheUrl,'!','/')
  94.             fnUrl = Translate(fnUrl,'!',':')
  95.             UrlFile = desktop||'\'||UrlFolder||'\'||fnUrl
  96.             ret = SysCreateObject('WebExplorer_Url', TheUrl,,
  97.                                    desktop||'\'||UrlFolder,,'replace');
  98.             if ret = 1 then do
  99.                 rc = charout(UrlFile,TheUrl);
  100.                 if rc <> 0 then say 'Couldn''t write to 'fnUrl
  101.                 rc = stream(UrlFile,'c','close')
  102.                 
  103.                 /* create COMMENT and TITLE */
  104.                 ln = ''
  105.                 ea = 'DFFF'x||'00'x||'00'x||D2C(RecordLines)||'00'x
  106.                 if length(ea)<256 then do
  107.                     do x = 1 to RecordLines
  108.                         ea = ea||'FDFF'x||D2C(Length(Arecord.x))||'00'x||Arecord.x
  109.                         
  110.                         /* create title */
  111.                         parse var Arecord.x what it_is
  112.                         select
  113.                             when what = 'From:' then do
  114.                                 if ln \= '' then ln = ln||d2c(13)||d2c(10)
  115.                                 ln = ln||it_is                                
  116.                             end
  117.                             when what = 'Newsgroups:' then do
  118.                                 if ln \= '' then ln = ln||d2c(13)||d2c(10)
  119.                                 ln = ln||it_is                                
  120.                             end
  121.                             when what = 'X-Newsgroups:' then do
  122.                                 if ln \= '' then ln = ln||d2c(13)||d2c(10)
  123.                                 ln = ln||it_is                                
  124.                             end
  125.                             when what = 'URL:' then do
  126.                                 if ln \= '' then ln = ln||d2c(13)||d2c(10)
  127.                                 ln = ln||it_is                                
  128.                             end
  129.                             otherwise
  130.                         end
  131.                     
  132.                     end
  133.                 end
  134.                 
  135.                 
  136.                 /* fix title */
  137.                 lp = 1;
  138.                 do while lp>0 
  139.                     lp = pos(',',ln,lp)
  140.                     if lp>0 then do
  141.                         insert('^',ln,lp)
  142.                         lp = lp + 2                        
  143.                     end
  144.                 end
  145.                 lp = 1;
  146.                 do while lp>0 
  147.                     lp = pos(';',ln,lp)
  148.                     if lp>0 then do
  149.                         insert('^',ln,lp)
  150.                         lp = lp + 2                        
  151.                     end
  152.                 end
  153.                 
  154.                 
  155.                 /* update some EA's and stuff */
  156.                 rc = SysPutEA(UrlFile, ".SUBJECT",,
  157.                    'FDFF'x||D2C(7)||'00'x||'Yep Url')
  158.                 rc = SysPutEA(UrlFile, ".COMMENTS", ea)                
  159.                 
  160.                 /* wish this didn't change the filename */
  161.                 /* trying to get the object title to have more data, but 
  162.                  it's messing everything up, so have left it alone for now */
  163.                 
  164. /*                say '=========='
  165.                 say ln
  166.                 say '----------'
  167.                 if ln \= '' then rc = SysPutEA(UrlFile, ".LONGNAME",,
  168.  'FDFF'x||D2C(length(ln))||'00'x||ln)
  169.                                          */
  170.                 say records||': '||TheUrl||' *ok*'
  171.             end
  172.             else say 'Couldn''t create to 'UrlFile
  173.         end
  174.         else say records||': '||theUrl||' *dupe*'
  175.     end    
  176. end
  177.  
  178.